package gdconf

import (
	"server_cluster/common/logger"
)

// 装备宝石配置表

type EquipJewelConfig struct {
	Id         int32 `csv:"id" gorm:"primary_key;autoIncrement:false"` // 装备宝石id
	JewelLevel int32 `csv:"JewLevel,omitempty"`                        // 宝石等级
	SkillGroup int32 `csv:"SkillGroup,omitempty"`                      // 技能组
	SkillLevel int32 `csv:"Level,omitempty"`                           // 技能等级
}

func (e *EquipJewelConfig) TableName() string {
	return "config_equip_jewel"
}

func (g *GameDataConfig) saveEquipJewelConfig() {
	saveTableToDb[EquipJewelConfig](g.Db, readTable[EquipJewelConfig](g.CsvPathPrefix+"equip_jewel.csv"))
}

func (g *GameDataConfig) loadEquipJewelConfig() {
	g.GameDataMaps.EquipJewelConfigMap = make(map[int32]*EquipJewelConfig)
	for _, equipJewelConfig := range loadTableFromDb[EquipJewelConfig](g.Db) {
		g.GameDataMaps.EquipJewelConfigMap[equipJewelConfig.Id] = equipJewelConfig
	}
	logger.Info("EquipJewelConfig Count: %v", len(g.GameDataMaps.EquipJewelConfigMap))
}

func GetEquipJewelConfig(id int32) *EquipJewelConfig {
	value, exist := CONF.GameDataMaps.EquipJewelConfigMap[id]
	if !exist {
		logger.Error("[ConfigNotFound] EquipJewelConfig, id: %v", id)
		return nil
	}
	return value
}

func GetEquipJewelConfigMap() map[int32]*EquipJewelConfig {
	return CONF.GameDataMaps.EquipJewelConfigMap
}
